
'''
# 显式转换
a = int(1)
b = int(1.2)
c = int(float('2.55'))
d = int(float("2.3"))

print("a = ", a, "b = ", b, "c = ", c, "d = ", d)
'''

'''
# list推导式
'''
names = ['Bob', 'ameny', 'alice', 'Jerry', 'Wendy', 'Smith']

new_names = [name.upper() for name in names if len(name) > 3]
# 名字长度>3,且名字是a开头，a大写，其他全大写
new_names2 = [name.title() if name.startswith('a') else name.upper() for name in names if len(name) > 3]
print(new_names2)

nums = [i for i in range(30) if i % 3 == 0]
# print(nums)

'''
# 字典推导式
listdemo = ['Google', 'Runoob', 'Taobao', 'Baidu']

dict_sites = {key: len(key) for key in listdemo}
print(dict_sites)

dict_pow = {num: num**2 for num in (2, 4, 6)}
print(dict_pow)

'''

'''
# 元组推导式

sites = {'Google', 'Taobao', 'Runoob', 'Facebook', 'Zhihu', 'Baidu'}

new_site = {site for site in sites if len(site) > 5}

print(new_site)

'''

''''
# 元组推导式
a = (x for x in range(1, 10))
print(a)
print(type(a))

print(tuple(a))
'''
